<?php

declare(strict_types=1);

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChOpenWorkApp;
use Hyperf\Cache\Annotation\Cacheable;
use Mine\Abstracts\AbstractMapper;

class ChOpenWorkAppMapper extends AbstractMapper
{
    public function assignModel()
    {
        $this->model = ChOpenWorkApp::class;
    }

    /**
     * 获取服务商应用信息
     * @param mixed $id
     * @return array
     */
    #[Cacheable(prefix: 'get_open_work_app_info',value: 'id_#{$id}',ttl: 15 * 60)]
    public function findById(mixed $id = 1): array
    {
        $info = $this->model::query()->where('id',$id)->first(['id','name','square_logo_url','description','suite_id','suite_secret']);
        return !empty($info) ? $info->toArray() : [];
    }
}